package ynu.edu.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ynu.edu.entity.Business;
import ynu.edu.service.BusinessService;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/BusinessController")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @PostMapping("/getBusinessById")
    public ResponseEntity<?> getBusinessById(@RequestBody Business params) {
        log.info("Received getBusinessById request with params: {}", params);
        Business business = businessService.getBusinessById(params.getBusinessId());
        log.info("Found business: {}", business);
        return ResponseEntity.ok(business);
    }

    @PostMapping("/listBusinessByOrderTypeId")
    public ResponseEntity<?> listBusinessByOrderTypeId(@RequestBody Business params) {
        log.info("Received listBusinessByOrderTypeId request with params: {}", params);
        List<Business> businesses = businessService.listBusinessByOrderTypeId(params.getOrderTypeId());
        log.info("Found businesses: {}", businesses);
        return ResponseEntity.ok(businesses);
    }
} 